package com.musicserver.controller;

import com.musicserver.common.R;
import com.musicserver.model.request.CommentRequest;
import com.musicserver.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
public class CommentController {
    @Autowired
    private CommentService commentService;

    //根据歌单id获取评论列表
    @GetMapping("/comment/songList/{songListId}")
    public R commentListOfSongListId(@PathVariable("songListId") Integer songListId) {
        return commentService.getCommentListBySongListId(songListId);
    }

    @GetMapping("/comment/song/{songId}")
    public R commentListOfSongId(@PathVariable("songId") Integer songId) {
        return commentService.getCommentListBySongId(songId);
    }

    @DeleteMapping("/comment/{id}")
    public R deleteComment(@PathVariable int id) {
        return commentService.removeById(id);
    }

    // 提交评论
    @PostMapping("/comment/add")
    public R addComment(@RequestBody CommentRequest addCommentRequest) {
        return commentService.addComment(addCommentRequest);
    }

    @PostMapping("/comment/like")
    public R commentOfLike(@RequestBody CommentRequest upCommentRequest) {
        return commentService.updateCommentMsg(upCommentRequest);
    }
}
